package com.egao.api.controller.orderB;


import com.egao.common.core.web.BaseController;
import com.egao.common.core.web.JsonResult;
import com.egao.common.system.service.OperRecordService;
import com.egao.orderB.entity.BillProcess;
import com.egao.orderB.service.BillProcessService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;

//import com.egao.orderB.entity.Bill;
//import com.egao.orderB.service.BillService;

/**
 * api登录相关接口
 * Created by wangfan on 2019-05-29 下午 3:43.
 * http://localhost/swagger-ui.html
 * https://francjc.com:4332/swagger-ui.html
 */
@RequestMapping("/api/billProcess")
@RestController
@Api(value = "订单流程状态管理",tags = {"订单流程状态管理"})
public class ApiBillProcessController extends BaseController {

    @Autowired
    private OperRecordService operRecordService;
    @Autowired
    private BillProcessService billProcessService;

    /**
     * 订单流程状态列表
     */
//    @PostMapping("/list")
//    @ApiOperation(value = "订单流程状态列表",notes = "" +
//            "limit:每页显示几行 必填\n" +
//            "billId:订单id 必填\n" +
//            "page:第几页 必填\n" +
//            " \n" +
//            "返回的内容\n" +
//            "id:id\n" +
//            "organizationId:组织id\n" +
//            "billId:订单id\n" +
//            "state:状态\n" +
//            "stateTime:状态时间\n" +
//            "",httpMethod = "POST")
//
//    public JsonResult list(PageResult2<T> page, BillProcess billProcess, HttpServletRequest request)  throws Exception{
//        operRecordService.saveAsync(new OperRecord(Integer.valueOf(getLoginUserId(request)), "订单流程状态列表", "订单流程状态列表",
//                request.getServletPath(), "POST", "ApiBillProcessController.list", request.getQueryString(),//JSONObject.toJSON(bill).toString(),
//                "", getIpAddress(request)));
//        return billProcessService.list(page, billProcess, getLoginUser());
//    }

    /**
     * 运费报价列表
     */
    @PreAuthorize("hasAuthority('orderB:billProcess:list')")
    @PostMapping("/listAll")
    @ApiOperation(value = "订单流程状态列表",notes = "" +
            "billId:订单id 必填\n" +
            "返回的内容\n" +
            "id:id\n" +
            "organizationId:组织id\n" +
            "billId:订单id\n" +
            "state:状态\n" +
            "stateTime:状态时间\n" +
            "",httpMethod = "POST")
    public JsonResult listAll(BillProcess billProcess, HttpServletRequest request)  throws Exception{
        return billProcessService.list(billProcess, getLoginUser());
    }


    /**
     * 添加订单流程状态
     */
//    @PostMapping("/save")
//    @ApiOperation(value = "添加订单流程状态",notes = "" +
//            "billId:订单id 必填\n" +
//            "state:状态\n" +
//            "",httpMethod = "POST")
//
//    public JsonResult save(BillProcess billProcess, HttpServletRequest request) {
//        operRecordService.saveAsync(new OperRecord(Integer.valueOf(getLoginUserId(request)), "添加订单流程状态", "添加订单流程状态",
//                request.getServletPath(), "POST", "ApiBillProcessController.save", request.getQueryString(),//JSONObject.toJSON(bill).toString(),
//                "", getIpAddress(request)));
//        return billProcessService.save(billProcess, getLoginUser());
//    }


    /**
     * 订单流程状态修改
     */
//    @PostMapping("/update")
//    @ApiOperation(value = "订单流程状态修改",notes = "" +
//            "id 订单流程状态的id 必填\n" +
//            "state:状态\n" +
//            "",httpMethod = "POST")
//
//    public JsonResult update(BillProcess billProcess, HttpServletRequest request) {
//        operRecordService.saveAsync(new OperRecord(Integer.valueOf(getLoginUserId(request)), "订单流程状态修改", "订单流程状态修改",
//                request.getServletPath(), "POST", "ApiBillProcessController.update", request.getQueryString(),//JSONObject.toJSON(bill).toString(),
//                "", getIpAddress(request)));
//        return billProcessService.update(billProcess, getLoginUser());
//    }

    /**
     * 订单流程状态删除
     */
//    @PostMapping("/remove")
//    @ApiOperation(value = "订单流程状态删除",notes = "" +
//            "id 订单流程状态的id 必填\n"
//            ,httpMethod = "POST")
//
//    public JsonResult remove(BillProcess billProcess, HttpServletRequest request) {
//        operRecordService.saveAsync(new OperRecord(Integer.valueOf(getLoginUserId(request)), "订单流程状态删除", "订单流程状态删除",
//                request.getServletPath(), "POST", "ApiBillProcessController.remove", request.getQueryString(),//JSONObject.toJSON(bill).toString(),
//                "", getIpAddress(request)));
//        return billProcessService.remove(billProcess, getLoginUser());
//    }


}
